﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.mainmenu {
    import flash.events.*;
    import org.robotlegs.core.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.components.mainmenu.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class InventoryTabMediator extends Mediator implements IMediator {

		[Inject]
        public var inventoryTabDisplay:InventoryTabDisplay;
		[Inject]
        public var inventoryModel:InventoryModel;

        override public function onRegister():void{
            eventMap.mapListener(_eventDispatcher, EventConstants.UPDATE_INVENTORY, this.updateItems);
            this.addItems();
        }
        private function addItems():void{
            var _local2:String;
            var _local1:Array = this.inventoryModel.getItemKeys();
            for each (_local2 in _local1) {
                this.inventoryTabDisplay.addItem(_local2, this.inventoryModel.getItemNumberByKey(_local2));
            };
        }
        private function updateItems(_arg1:Event):void{
            var _local3:String;
            var _local4:InventoryScrollItem;
            var _local2:Array = this.inventoryModel.getItemKeys();
            for each (_local3 in _local2) {
                _local4 = this.inventoryTabDisplay.getItemByKey(_local3);
                _local4.numberOfItems = this.inventoryModel.getItemNumberByKey(_local3);
            };
        }

    }
}//package net.wooga.pets.views.mainmenu 
